#ifndef _FORMATION
#define _FORMATION

#include <Ogre.h>
#include <hash_set>

#include "Core/CoreManager.h"
#include "Core/GameFactor.h"
//#include "Part.h"
#include "Core/Unit.h"

namespace Core
{
	class Formation
	{
	public:
		Formation(Unit *unit,Player *player=0):mPlayer(player)
		{
			//mMinUnits=unit->getType()->getMaxUnits();
			//mMaxUnits=unit->getType()->getMinUnits();

			for (int i=0;i<mMinUnits;i++)
				addUnit(unit);
		}
		bool addUnit(Unit *unit)
		{
			if (mUnits.size()>=mMaxUnits)
				return false;
			mUnits.push_back(unit->clone());
			return true;
		}
		bool removeUnit()
		{
			if (mUnits.size()<=mMinUnits)
				return false;
			Unit *unit = mUnits.back();
			mUnits.pop_back();
			delete unit;
			return true;
		}
		void killUnit(Unit *unit)
		{
			mUnits.erase(unit);
			//BattleManager::getSingeltonPtr()->addUnitToKilled(unit);
				
			if (mUnits.empty())
				//BattleManager::getSingeltonPtr()->removeFormation(this);
		}

		void setPlayer(Player *player){mPlayer=player;}
		Player *getPlayer(){return mPlayer;}
	private:
		stdext::hash_set<Unit *> mUnits;
		
		Player *mPlayer;
		String mName;
		/*int mNumOfBattles;
		ulong mCombatPoints;	
		int mUnitsLost;
		int mUnitsKilled;
		int mFormationsKilled;*/

		ubyte mMinUnits;
		ubyte mMaxUnits;
	};
}
#endif